﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Amazon.Route53.WCFExtension
{
    public class CustomWebHttpBehavior : System.ServiceModel.Description.WebHttpBehavior
    {
        private String AWSAccessKey
        {
            get;
            set;
        }
        private String AWSSecretAccessKey
        {
            get;
            set;
        }

        public CustomWebHttpBehavior(string awsAccessKey, string awsSecretAccessKey)
        {
            this.AWSAccessKey = awsAccessKey;
            this.AWSSecretAccessKey = awsSecretAccessKey;
        }

        public override void ApplyClientBehavior(System.ServiceModel.Description.ServiceEndpoint endpoint
            , System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
        {
            clientRuntime.MessageInspectors.Add(new AuthenticationMessageInspector(AWSAccessKey, AWSSecretAccessKey));
            base.ApplyClientBehavior(endpoint, clientRuntime);
        }

        protected override System.ServiceModel.Dispatcher.IClientMessageFormatter GetReplyClientFormatter(System.ServiceModel.Description.OperationDescription operationDescription, System.ServiceModel.Description.ServiceEndpoint endpoint)
        {
            return base.GetReplyClientFormatter(operationDescription, endpoint);
        }

        protected override System.ServiceModel.Dispatcher.IDispatchMessageFormatter GetReplyDispatchFormatter(System.ServiceModel.Description.OperationDescription operationDescription, System.ServiceModel.Description.ServiceEndpoint endpoint)
        {
            return base.GetReplyDispatchFormatter(operationDescription, endpoint);
        }
    }
}
